<style>
	.login_page { width: 100%; height: 400px; display: flex; flex-flow: column nowrap; justify-content: center; align-items: center; }
	.login_page input { width: 300px; height: 32px; margin-top: 20px; }
	.login_page button { width: 120px; height: 32px; margin-top: 20px; }
</style>

<article class="login_page">
	<input type="text" name="userName" placeholder="请输入用户名">
	<input type="password" name="password" placeholder="请输入密码">
	<button class="btn_login">登录</button>
</article>


<script>
	$().ready(function(){
		
		// 先清除原来的登录信息
		window.sessionStorage.removeItem('userlogin');
		$("button.btn_login").click(function(){

			var condition = JSON.stringify({login_name: $("input[name=userName]").val(), password: hex_md5($("input[name=password]").val()), user_status: 1});
			console.log(condition)
			$.get(dataDomain + "curd.php", {do: 'select', table: 'tj.operation_users', conditions: condition} , function(r){
				console.log(r)
				if(r.length > 0){
					if( r[0].right_id < 10){
						var userlogin = JSON.stringify({userName: r[0].user_name, userID: r[0].user_id, user_type: r[0].user_type, right_id: r[0].right_id});
						// console.log(userlogin)
						window.sessionStorage.setItem('userlogin', userlogin);
						window.location.reload();	
					}else{
						alert('您没有PC端的查询权限，请使用移动端版本');
					}
				}else{
					alert('用户名或密码不正确, 或者无权限')
				}
			}, 'json')
		})

		$("input[name=userName], input[name=password]").keyup(function(e){
			if(e.keyCode == 13){
				$("button.btn_login").click();
			}
		})
	})
</script>